
			function Move(a)
			{
				a.click(function()
				{
						a.css('transform','rotate('+Math.random()*50+'deg)');
				})
				var OX,OY,ismove;
				a.mousedown(function(e)
				{
					ismove=true;
					OX= e.pageX-parseInt(a.css('left'));
					OY= e.pageY-parseInt(a.css('top'));
					a.css({'background':'black','z-index':9999});
				})
				$('#photos').mousemove(function(e)
				{
					if (ismove==true) 
					{
						var top=e.pageY-OY;
						var left=e.pageX-OX;
						left=left<0?0:left;
						left=left>=$(window).width()-parseInt(a.css('width')+20)?$(window).width()-parseInt(a.css('width')):left;
						top=top<=0?0:top;
						top=top>=parseInt($('#photos').css('height'))-parseInt(a.css('height'))?parseInt($('#photos').css('height'))-parseInt(a.css('height')):top;
						a.css({'top':top,'left':left});
					};
				}).mouseup(function()
				{
					ismove=false;
					a.css({'background':'white'});
				})
			}
			
			function ViewImages(images,path)
			{	
				var CurrentIndex=1;
				var Wwidth=$('#photos').width(),Wheight=$('#photos').height();
				//var tmpl="";
				var left=0,top=0;
				var photos=$('.photos');
				for (var i = 0; i <images.length; i++) {
					left=Math.floor(20+Math.random()*(Wwidth-200));
					top=Math.floor(20+Math.random()*(Wheight-220));
					var AnimationIndex=Math.floor(Math.random()*5);
					var a=$('<a date-path="'+imgPath+'"  ></a>');
					a.css({'transform':'rotate('+Math.random()*90+'deg)','top':top,'left':left});
					Move(a);
					var imgPath=path+images[i].photosort_id+'/'+images[i].filename;
					a.append('<canvas date-description="'+images[i].description+'"  date-path="'+imgPath+'" id="cans_'+images[i].id+'"></canvas>		');
					$("#photos").append(a);
					//tmpl+='<a date-path="'+i+'" class="'+InFun[AnimationIndex]+'" style="left:'+left+';top:'+top+'"><canvas  date-path="'+i+'" id="cans_'+i+'"></canvas></a>';
					//$("#photos").html(tmpl);
					var imgObj=new Image();
					imgObj.index=images[i].id;
					imgObj.onload=function()
					{
						var hei=200;
						if (this.height/this.width>1.2)
						{
							hei+=Math.floor(Math.random()*50);
						}
						$("#cans_"+this.index).parent('a').css('height',hei);
						var cav=$("#cans_"+this.index)[0].getContext("2d");
						cav.drawImage(this,0,0,400,400);
					}
					imgObj.src=imgPath;
				};

				$('#photos canvas').click(function()
				{	
					//CurrentIndex=$(this).index();
					loadImage($(this));
				})
					var large_img=$('#large-img');
					var description=$('#large-img-description');
					//加载大图
					function loadImage(E){
						Wwidth=$(window).width(),Wheight=$(window).height();
						var Path=E.attr('date-path');
						description.text(E.attr('date-description'));
						$(large_img).fadeOut(0);
						$('.large').css({width:Wwidth,height:Wheight}).show();
						large_img.css('padding-left',"0px").css('padding-top',"0px");
						large_img.css('width',"auto").css('height',"auto");
							var Limg=new Image();
							Limg.onload=function()
							{
								$(large_img).fadeIn();
								var w=this.width;
								var h=this.height;
						
								if (h/w>1.2)
								 {
								 	var viewW=Wheight*w/h;
								 	var paddingLeft=parseInt((Wwidth-viewW)/2);
								 	large_img.attr('src',imgPath).css('height',Wheight).css('padding-left',paddingLeft);
								 }else{
								 	var viewH=Wwidth*h/w;
								 	var paddingTop=parseInt((Wheight-viewH)/2);
								 	 large_img.attr('src',Path).css('width',Wwidth).css('padding-top',paddingTop);
								 }
							};
						Limg.src=Path;
					}

					$('.closePage').click(function()
					{
						$('.large').fadeOut();
					})
					$('.nextPage').click(function()
					{
						//alert($('#photos a'));
						CurrentIndex+=1;
						if(CurrentIndex>=$('#photos canvas').length)
							CurrentIndex=$('#photos canvas').length-1;
						loadImage($('#photos canvas:eq('+CurrentIndex+')'));
					})
					$('.prevPage').click(function()
					{
						if(CurrentIndex<0)
							CurrentIndex=0;
						if (CurrentIndex!=0)
						{				
							CurrentIndex-=1;
							loadImage($('#photos canvas:eq('+CurrentIndex+')'));
						}
					})		
			}